<template>
  <div class="app-container">
    <h1>App 根组件</h1>
    <hr/>
    <EsHeader title="购物车案例"></EsHeader>
  </div>
</template>

<script>
import EsHeader from "./components/EsHeader.vue";

export default {
  name: 'App',
  components: {
    EsHeader,
  },
  data() {
    return {
      goodList: [],
    }
  },
  created() {
    this.getGoodsList();
  },
  methods: {
    async getGoodsList() {
      const {data: res} = await this.$http.get('/api/cart');
      if (res.status !== 200)
        return alert('获取商品失败！');
      this.goodList = res.list;
    }
  }
}
</script>
<style lang="less" scoped>
.app-container {
  padding-top: 450px;
}
</style>